package com.woniuxy.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import com.woniuxy.pojo.FindRoom;
import com.woniuxy.pojo.OrderDetail;
import com.woniuxy.pojo.Order_dgy;
import com.woniuxy.pojo.Room;
import com.woniuxy.pojo.RoomImg;
import com.woniuxy.pojo.RoomType;
import com.woniuxy.pojo.RoomType_dgy;
import com.woniuxy.pojo.RoomTypocj;
import com.woniuxy.provider.FindRoomProvider;
import com.woniuxy.provider.RoomTypeProvider;

public interface RoomTypeMapper {
	//统计房间类别的总数
	@Select("SELECT COUNT(*) 'counts',rtid FROM room GROUP BY rtid;")
	public List<RoomTypocj> findRoomCount();
	//查询已住房间类型的个数
	@Select(" SELECT COUNT(*) 'counts',rtid FROM orderdetail WHERE ((#{checkin} BETWEEN checkin AND checkout) "
			+ "AND (#{checkout} BETWEEN checkin AND checkout)) and dele=0 GROUP BY rtid")
	public List<RoomTypocj> findkzRoomCount(OrderDetail orderDetail);
	
	@Select(" SELECT *FROM roomtype WHERE rtid=#{rtid}")
	public RoomType findRoomTypes(Integer rtid);
	
	//多条件查询
	List<RoomType> findTypeandfw();
	//模糊查询
		@SelectProvider(type=RoomTypeProvider.class,method="manyfindRoomTypes")
		public List<RoomType> findManyRoomType(RoomType roomType);
		
		@Select("select *from roomtype where rtid=#{rtid}")
		@Results({
			@Result(id=true,column="rtid",property="rtid"),
			@Result(column="rname",property="rname"),
			@Result(column="rwindow",property="rwindow"),
			@Result(column="rfood",property="rfood"),
			@Result(column="rspring",property="rspring"),
			@Result(column="rprice",property="rprice"),
			@Result(column="rmessage",property="rmessage"),
			@Result(column="rtid",property="myimgs",
			many=@Many(
					select="findRoomTypeImg"))
		})
		public RoomType findRoomTypess(int rtid);
		//一个房间类型对应多个图片
		
		@Select("select *from roomimg where rtid=#{rtid}")
		public List<RoomImg> findRoomTypeImg(int rtid);
		
		@Select("select * from roomType")
		List<RoomType_dgy> findRoomType(Order_dgy order);
}
